< previous page page_604 next page >

Page 604
9f31265bb40b592b1929e18a47ab28e5.gif
   lstKeys.Clear
   For intLoop = LBound(astrKeys) To UBound(astrKeys)
      lstKeys.AddItem astrKeys(intLoop)
   Next

   Set oReg = Nothing
End Sub
In this code, you need to declare an array of variants. The ConfigName and Section properties of the Registry class are then filled in. When the SectionGet() method is called, it returns a Variant array of strings. The code then loops through this array and loads the keys and values into a list box.
The SectionGet() Method in the Registry Class
The SectionGet() method accepts an optional argument of which section to get keys from. This method creates a Variant array that returns a two-dimensional array from the GetAllSettings() function. Instead of having a two-dimensional array returned, I like to have a single-dimensional array returned with the keyed pair in each element. Therefore, after retrieving the array from the GetAllSettings() function, I loop through the array and convert it to a single-dimensional array by concatenating the value in the first element with an equal sign and the value in the second element. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Public Function SectionGet( _
               Optional strSection As String = "") _
               As Variant()
   Dim lngRet As Long
   Dim astrAll As Variant
   Dim astrKeys() As String
   Dim intLoop As Integer

   If strSection <> "" Then
      mstrSection = strSection
   End If

   If mstrSection <> "" Then
      astrAll = GetAllSettings(mstrConfigName, mstrSection)
      If Not IsEmpty(astrAll) Then

 
< previous page page_604 next page >

If you like this book, buy it!